/*
 * $Id: svn.h 7557b5d4d82b 2012/12/02 09:07:16 pgurumur $
 *
 * Copyright (c) 2006, 2007, 2008 Prabhu Gurumurthy <pgurumur@gmail.com>
 *
 * Permission to use, copy, modify, and distribute this software for any
 * purpose with or without fee is hereby granted, provided that the above
 * copyright notice and this permission notice appear in all copies.
 *
 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 */

/*
 * version "$Revision: 7557b5d4d82b $"
 * author "$Author: pgurumur $"
 */

#ifndef __TCLSVN_H_
#define __TCLSVN_H_

#ifdef __linux__
#define _LARGEFILE64_SOURCE
#endif

#include <sys/types.h>

#include <err.h>
#include <errno.h>
#include <stdarg.h>
#include <unistd.h>

#include <svn_client.h>
#include <svn_cmdline.h>
#include <svn_pools.h>
#include <svn_config.h>
#include <svn_fs.h>
#include <svn_time.h>
#include <svn_wc.h>

#include <tcl.h>

#define MAXLINE 8192

struct _tclsvn {
   apr_pool_t *pool;
   svn_error_t *error;
   svn_opt_revision_t rev;
   apr_hash_t *dirents;
   apr_hash_index_t *index;
   svn_client_ctx_t *ctx;
   Tcl_Interp *interp;
   int client;
};

struct _tclsvn *svn_t;
char errmsg[MAXLINE];

void subversion_client(const char *);

void error(const char *, ...);
void cleanup(void);

int init_svn(ClientData, Tcl_Interp *, int, Tcl_Obj *const *);
void delete_svn(ClientData);

int Svn_Init(Tcl_Interp *);

void notify_func(void *, const svn_wc_notify_t *, apr_pool_t *);
svn_error_t *recv_cb(void *, const char *, const svn_dirent_t *, 
      const svn_lock_t *, const char *, apr_pool_t *);
svn_error_t *status_cb(void *, const char *, svn_wc_status2_t *, apr_pool_t *);
svn_error_t *info_cb(void *, const char *, const svn_info_t *, apr_pool_t *);
svn_error_t *userpw_cb(svn_auth_cred_simple_t **, void *, const char *,
      const char *, svn_boolean_t, apr_pool_t *);
svn_error_t *user_cb(svn_auth_cred_username_t **, void *, const char *,
      svn_boolean_t, apr_pool_t *);
svn_error_t *logmsg_cb(const char **, const char **,
      const apr_array_header_t *, void *, apr_pool_t *);
svn_error_t * sslserver_cb(svn_auth_cred_ssl_server_trust_t **, void *,
      const char *, apr_uint32_t, const svn_auth_ssl_server_cert_info_t *,
      svn_boolean_t, apr_pool_t *);
svn_error_t *plainpass_cb(svn_boolean_t *, const char *, void *, apr_pool_t *);
svn_error_t *sslclient_cb(svn_auth_cred_ssl_client_cert_t **, void *,
      const char *, svn_boolean_t, apr_pool_t *);
svn_error_t *sslpw_cb(svn_auth_cred_ssl_client_cert_pw_t **, void *,
      const char *, svn_boolean_t, apr_pool_t *);

#endif

